#pragma once

#include <exception>
#include <string>

class Exception : public std::exception
{
public:
	Exception(int code = 0, const std::string& message = "");
	Exception(const Exception& rhs);
	Exception& operator = (const Exception& rhs);
	~Exception() throw ();

	virtual const char* what() const throw ();

	int GetCode() const;
	const std::string& GetMessage() const;
	std::string GetDisplayText() const;
private:
	std::string m_message;
	int m_code;
};

// standard exceptions
typedef Exception ParseException;


template <typename E>
inline void ThrowException(int code, const std::string& message)
{
	E e(code, message);
	throw e;
}

template <typename E>
inline void ThrowException(const std::string& message)
{
	E e(0, message);
	throw e;
}

template <typename E>
void ThrowException(const std::string& message, const std::string& description);

template <typename E>
inline void ThrowException(int code)
{
	E e(code);
	throw e;
}
